package com.weilele.leisure.video_factory.ui.module.video_factory

import android.os.Build
import android.os.Bundle
import android.os.Environment
import com.weilele.base.library.BaseBindingFragment
import com.weilele.leisure.time.R
import com.weilele.leisure.time.databinding.FragmentVideoFactoryBinding
import com.weilele.leisure.time.ui.module.video_cache.VideoCacheFragment
import com.weilele.leisure.video_factory.ui.module.common.dialog.PermissionTipsDialog
import com.weilele.leisure.video_factory.ui.module.common.holder.HomeToolsItemHolder
import com.weilele.leisure.video_factory.ui.module.local_video.LocalVideoFragment
import com.weilele.leisure.video_factory.ui.module.sniff.SniffFragment
import com.weilele.mvvm.adapter.refreshList
import com.weilele.mvvm.base.livedata.appCompatActivity

/**
 * 在线播放，缓存，下载
 * 入口
 */
class VideoFactoryFragment : BaseBindingFragment<FragmentVideoFactoryBinding>() {
    private val rcvAdapter = HomeToolsItemHolder.toAdapter()
    override fun initUi(savedInstanceState: Bundle?) {
        super.initUi(savedInstanceState)
        mBinding.title.setText(R.string.title_tools)
        mBinding.rcv.adapter = rcvAdapter
        initRcvData()
    }

    private fun initRcvData() {
        val datas = mutableListOf<HomeToolsItemHolder.Bean>()
        //本地视频
        datas.add(HomeToolsItemHolder.Bean(
            getString(R.string.local_video)
        ) {
            LocalVideoFragment.start(appCompatActivity)
        })
        datas.add(HomeToolsItemHolder.Bean(
            getString(R.string.play_online)
        ) {
            SniffFragment.start(this)
        })
        datas.add(HomeToolsItemHolder.Bean(
            getString(R.string.library_video_cache)
        ) {
            VideoCacheFragment.start(appCompatActivity!!)
        })
        rcvAdapter.refreshList(datas)
    }
}